﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Abp.Authorization.Users;
using Abp.Extensions;
using SOEI.Solution.Customized;
using static SOEI.Solution.AppCoreConst;

namespace SOEI.Solution.Authorization.Users
{
    public class User : AbpUser<User>
    {
        public const string DefaultPassword = "123qwe";

        public static string CreateRandomPassword()
        {
            return Guid.NewGuid().ToString("N").Truncate(16);
        }

        public static User CreateTenantAdminUser(int tenantId, string emailAddress)
        {
            var user = new User
            {
                TenantId = tenantId,
                UserName = AdminUserName,
                Name = AdminUserName,
                Surname = AdminUserName,
                EmailAddress = emailAddress,
                Roles = new List<UserRole>()
            };

            user.SetNormalizedNames();

            return user;
        }

        #region ---------------------------------用户字段扩展-----------------------------


        /// <summary>
        /// 经济机构编号
        /// </summary>
        public virtual long? OrganizeID { get; set; }

        /// <summary>
        /// 用户类型 (0 .默认类型（系统类型） 1 . 机构管理员（系统）,2 . 机构管理员（用户）3 .机构人员（用户）
        /// </summary>
        public virtual EUserType UserType { get; set; }

        ///<summary>
        /// 状态编码
        ///</summary>
        [Description("状态编码")]
        [MaxLength(EntityLength.Length20)]
        public virtual string StateCode { get; set; }

        /// <summary>
        /// 原始编号（Zhxt中的机构编号 JGBH）
        /// </summary>
        [Description("原始编号")]
        [MaxLength(EntityLength.Length20)]
        public virtual string OriginalNumber { get; set; }


        /// <summary>
        /// 原始密码（这个密码就是为了同步老系统的明文密码）
        /// </summary>
        [Description("原始密码")]
        [MaxLength(EntityLength.Length20)]
        public virtual string OriginalPassword { get; set; }

        /// <summary>
        /// 唯一的移动电话（以后通过手机号就用这个）
        /// </summary>
        //[MaxLength(EntityLength.Length20)]
        //public virtual string MobilePhone{get;set;}

        #endregion
    }
}
